<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>文件导入</title>
<link href="${ctx}/style/upload.css" rel="stylesheet" />
<link href="${ctx}/style/font.css" rel="stylesheet" />
<script src="${ctx}/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="bg">
	<span class="bth_file">导入EXCEL</span>
    	<div class="input_file" hidden>
    	  <!-- 默认调用错误和正确第一页信息  -->
	      <form action="${ctx}/admin/upload/1-1" method="post" enctype="multipart/form-data" id="submit">
		     <input type="file" accept="*.xls" name="excelFile" id="checkFile"/>
	      </form>
	    </div>
    	<div class="center lin_hd_60 wid_35 bor_bottom mar_centet input_filel"></div>
	    <span class="bth_file_ok" >ok</span>
</div>
<script>
var text_mun="";
$(function(){
	//起始清空
	$("input[type='file']").val('');
	text_mun = $("input[type='file']").val();
	$(".bth_file").live("click",function(){
		$("input[type='file']").click();
		input_time();
	});
	$(".bth_file_ok").live("click",function(){
		if(text_mun == ""){
			alert("请先选择文件！");
			return;
		}
		if(checkFile() != 0 ){
			alert("请先选择xls文件！");
			return;
		}
		$('#submit').submit();
	});
	input_time();
});
function input_time(){
	var text = $("input[type='file']").val();
	console.log("读取到文件数据变动信息:"+text);
	if(text_mun != text){
	console.log("开始变动-----1----:"+text_mun);
		$(".input_filel").text(text);
	console.log("开始变动------2---:"+text_mun);
		text_mun = text;
		return;
	}
	s = setTimeout(input_time,1)
}

		//检查文件是否符合xls
		function checkFile(){
             var file =    $('#checkFile').val();
		     console.log(file);
	          var fl = file.split(".");
	         //常用的文件格式
	          var ary = ["xls"];
	        //文件格式在数组中返回下标，否则返回 -1
     	     var t= $.inArray(fl[1],ary);
	       	console.log(t);
	       	return t;
		}
		
</script>
</body>
</html>